﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ETM.Business.Models;
using ETM.Data.DataTransferObjects;
using ETM.Data.Interfaces;
using ETM.Data.Repositories;

namespace ETM.Business.Handlers
{
    public class EditTask
    {
        private readonly ITaskRepository taskRepo;

        public EditTask()
        {
            taskRepo = TaskMockupRepository.Instance;
        }

        public Task AddOne(string taskName, string taskStatus, bool isUrgent, bool isImportant)
        {
            var result = taskRepo.AddTaskEntity(taskName, taskStatus, isUrgent, isImportant);

            return new Task
                       {
                           TaskId = result.TaskId, 
                           TaskStatus = result.TaskStatus, 
                           TaskName = result.TaskName,
                           IsUrgent = result.IsUrgent,
                           IsImportant = result.IsImportant
                       };

        }

        public Task AddOne(Task importTask)
        {
            var result = taskRepo.AddTaskEntity(importTask.TaskName, importTask.TaskStatus, importTask.IsUrgent, importTask.IsImportant);

            return new Task
            {
                TaskId = result.TaskId,
                TaskStatus = result.TaskStatus,
                TaskName = result.TaskName,
                IsUrgent = result.IsUrgent,
                IsImportant = result.IsImportant
            };

        }

        public string DeleteOne(string taskId)
        {
            var result = taskRepo.DeleteTaskEntity(taskId);

            return result;

        }

        public Task Finish(string taskId)
        {
            var result = taskRepo.FinishTaskEntity(taskId);
            return new Task
            {
                TaskId = result.TaskId,
                TaskStatus = result.TaskStatus,
                TaskName = result.TaskName,
                IsUrgent = result.IsUrgent,
                IsImportant = result.IsImportant
            };

        }
    }
}
